`
https://leetcode.cn/problems/corporate-flight-bookings/
`

/**
 * @param {number[][]} bookings
 * @param {number} n
 * @return {number[]}
 */
var corpFlightBookings = function (bookings, n) {
  const diff = new Array(n).fill(0)
  for (const b of bookings) {
    const i = b[0] - 1, j = b[1] - 1, val = b[2]
    diff[i] += val
    if (j + 1 < n) {
      diff[j + 1] -= val
    }
  }
  const answer = new Array(n)
  answer[0] = diff[0]
  for (let i = 1; i < n; i++) {
    answer[i] = diff[i] + answer[i - 1]
  }

  return answer
};